﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Text.Editor.DragDrop;
using System.Diagnostics;
using FunctionPoint.Common;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;

namespace FunctionPoint.Handlers
{
    public class CodeDragDropHandler : DropHandlerBase
    {

        public CodeDragDropHandler(IWpfTextView wpfTextView, IEditorOperations editorOperations):
            base(wpfTextView, editorOperations)
        {

        }

        protected override string ExtractText(DragDropInfo dragDropInfo)
        {
            
            string extractedText = string.Empty;
            if (dragDropInfo.Data.GetDataPresent(Constants.DROPHANDLER_DROPFORMAT_TEXT))
                extractedText = dragDropInfo.Data.GetData(Constants.DROPHANDLER_DROPFORMAT_TEXT).ToString();

            Debug.WriteLine("CodeDragDropHandler:ExtractText:\r\nSource:{0}\r\nLocation:{1},{2}\r\n,ExtractedText:{3} ", new object[] { dragDropInfo.Source, dragDropInfo.Location.X.ToString(), dragDropInfo.Location.Y.ToString(), extractedText });

            return extractedText;
        }

        protected override void PerformPostEditActions(DragDropInfo dragDropInfo, bool successfulEdit)
        {
            return;
        }

        protected override void PerformPreEditActions(DragDropInfo dragDropInfo)
        {
            return;
        }

        protected override DragDropPointerEffects GetDragDropEffect(DragDropInfo dragDropInfo)
        {
            
            return base.GetDragDropEffect(dragDropInfo);
        }
        public override DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo)
        {
            return base.HandleDataDropped(dragDropInfo);
        }

        public override DragDropPointerEffects HandleDraggingOver(DragDropInfo dragDropInfo)
        {
            
            return base.HandleDraggingOver(dragDropInfo);
        }

        public override DragDropPointerEffects HandleDragStarted(DragDropInfo dragDropInfo)
        {
            return base.HandleDragStarted(dragDropInfo);
        }

        protected override bool InsertText(Microsoft.VisualStudio.Text.VirtualSnapshotPoint position, string data)
        {
            // return base.InsertText(position, data);
            return true;
        }
    }
}
